using UnityEngine;
using System.Collections;

public class PlayerHealth : MonoBehaviour {
	public int maxHealth = 100;
	public int curHealth = 100;
	
	public float healthBarLength;
	
	
	// Use this for initialization
	void Start () {
		healthBarLength = 200;
	}
	
	// Update is called once per frame
	void Update () {
		AdjustCurrentHealth(0);
	}
	
	void OnGUI() {
		GUI.Box(new Rect(9,9,(maxHealth * 2) + 2,22),"");
		GUI.Box(new Rect(10,10,(healthBarLength),20), "");
		GUI.Label(new Rect(10,10,(maxHealth*2),20), "Health: " + curHealth + "/" + maxHealth);
	}
	
	public void AdjustCurrentHealth(int adjust){
		curHealth += adjust;
			
		healthBarLength = (curHealth * 2);
		if(curHealth > maxHealth)
		{
			curHealth = maxHealth;
		}
		if(curHealth < 0)
		{
			curHealth = 0;
		}
		if(maxHealth < 1)
		{
			maxHealth = 1;
		}
	}
}

